package com.qf.web.controller;

import com.qf.domain.Stu;
import com.qf.service.StuService;
import com.qf.service.impl.StuServiceImp;
import com.qf.utils.StringUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * projectName:test_stu
 * author:lcy
 * time:2023/12/8 17:29
 * description:
 */
@WebServlet("/updateU")
public class UpdateUServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //String id = request.getParameter("id");
        //if(StringUtils.isEmpty(id)){
        //    request.setAttribute("msg","id不能为空");
        //    request.getRequestDispatcher("message.jsp");
        //    return;
        //}
        StuService stuService=new StuServiceImp();
        Stu stu=new Stu();
        //int bid=Integer.parseInt();
        try {
             stu=stuService.findById(stu.getId());
            request.setAttribute("stu", stu);
            request.getRequestDispatcher("/message.jsp");
        } catch (Exception e) {
            e.printStackTrace();
            request.setAttribute("msg", "失败");
            request.getRequestDispatcher("message.jsp").forward(request,response);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}


